using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InputController : MonoSingleton<InputController>
{
    public Joystick joystick;
    private Vector2 lastDirection;
    public Vector2 RamdomDirection()
    {
        float angle = Random.Range(0f, 2f * Mathf.PI);
        return new Vector2(Mathf.Cos(angle),Mathf.Sin(angle));
    }
    public Vector2 GetDirection()
    {
        if(joystick.Direction.sqrMagnitude>0.01f)
        {
            lastDirection = joystick.Direction;
            return joystick.Direction;
        }
        else
        {
            return lastDirection;
        }
    }
    public override void Awake()
    {
        lastDirection = RamdomDirection();
        base.Awake();
    }
}
